package com.bawan.vims.common.util;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.ResourceBundle;

import com.alibaba.druid.pool.DruidDataSource;

/**
 * <p> Description	: DataSourceUtil.java </p>
 * <p> Copyright	: Copyright (c) 2015 by FITT</p>
 * <p> Author 		: ZCC </p>
 * <p> Create		: 2015年1月29日 下午5:30:33 </p> 
 * <p> version 		: 1.0 </p>
 */
public enum DataSourceUtil {
	DATASOURCE;
	private DruidDataSource dds = null;
	
	private DataSourceUtil() {
		try {
			ResourceBundle rs = ResourceBundle.getBundle("*.properties");
			dds = new DruidDataSource();
			dds.setUrl(rs.getString("jdbc.url"));
			dds.setUsername(rs.getString("jdbc.username"));
			dds.setPassword(rs.getString("jdbc.password"));
			dds.setMaxActive(Integer.valueOf(rs.getString("jdbc.maxActive")));		
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public Connection getConnection() {
		try {
			return dds.getConnection();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return null;
	}
}
